package com.code.question1.base;

import com.code.question1.impl.StudentAgeException;

import java.io.Serializable;

public abstract class User<T> implements Oprator<T>, Serializable {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(String age) throws StudentAgeException {
        String regAge = "[1-9]\\d{1}";
        if (!age.matches(regAge)) {
            throw new StudentAgeException("输入年龄格式有误，请输入正确格式的年龄");
        }
        this.age = Integer.parseInt(age);
    }
}
